<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>详情</title>

    <link rel="stylesheet" href="./node_modules/layui/dist/css/layui.css" />

    <script type="text/javascript" src="./node_modules/layui/dist/layui.js"></script>
    <script type="text/javascript" src="./node_modules/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="./js/site.js"></script>
    <script type="text/javascript" src="./js/config.js"></script>
</head>
<body>
    <table style="width: 577px; height: 300px; margin: 10px;">
        <tr>
            <td>
                <textarea id="cbrief" style="height: 260px; width: 560px; padding: 10px;">&nbsp;</textarea>
            </td>
        </tr>
        <tr style="height: 30px;">
            <td style="text-align: center; margin-top: 10px;">
                <button id="btnSave" class="layui-btn">保存</button>
            </td>
        </tr>
    </table>
    <script>
        $(document).ready(() => {
            let ck = new CookieSettings();
            let paras = ck.getUrlVars();
            let id = paras.id;
            let detail = new DetailOperation();

            detail.SetBrief(id);

            $("#btnSave").on("click", function() {
                let formData = new FormData();

                formData.append("id", id);

                let cbrief = $("#cbrief").val();
                formData.append("cbrief", cbrief);

                let myUrl = apiurl + "/reg/infointro/cbrief";

                $.ajax({
                    url: myUrl,
                    type: 'PUT',
                    cache: false,
                    data: formData,
                    processData: false,
                    contentType: false
                }).done(function (res) {
                    layer.alert("保存成功！" + id);
                }).fail(function (res) {
                    layer.alert("保存失败！" + id);
                });

            });
        });

        function DetailOperation() {
            this.SetBrief = function(id) {
                let myUrl = apiurl + "/reg/infointro/cbrief/" + id;

                $.ajax({
                    url: myUrl,
                    type: 'GET',
                    cache: false,
                    processData: false,
                    contentType: false
                }).
                done(function (res) {
                    $("#cbrief").val(res);
                }).
                fail(function (res) {
                    $("#cbrief").val("");
                });

            }
        }
    </script>
</body>
</html>